home *** CD-ROM | disk | FTP | other *** search
/ PC Open 95 / PC Open 95 CD1.bin / cifratura / Rip Coder / ripcoder15f / PlugSrc / RIPPlug.dpr
Encoding:
Text File  |  2003-05-11  |  2.2 KB  |  113 lines

  1.  
  2. library RIPPlug;
  3.  
  4. uses
  5.   Windows, SysUtils;
  6.  
  7. {
  8.   --------------------------------
  9.   PlugIn system for RIPcoder v1.00
  10.   --------------------------------
  11.  
  12.   You can build your plugins for use it in RIPcoder.
  13.   This example is "simple XOR-32" method which works with 32bits key.
  14.   It's just a demo of "how to make plugin for RIPcoder".
  15.  
  16.   (!) DON'T USE THIS METHOD FOR DATA ENCRYPTION!
  17. }
  18.  
  19. const
  20.  PlugName       = 'Simple XOR-32';
  21.  PlugVersion       = '1.0';
  22.  
  23. var
  24.  key32    : integer;
  25.  
  26. function PlugIn_Name: pchar; stdcall;
  27. begin
  28.  result := PlugName;
  29. end;
  30.  
  31. function PlugIn_Version: pchar; stdcall;
  32. begin
  33.  result := PlugVersion;
  34. end;
  35.  
  36. {
  37.   RIPcoder install plugin by calling "pg_InitPlugIn"
  38. }
  39. function pg_InitPlugIn: bool; stdcall;
  40. begin
  41.  { this is place for initialization }
  42.  result := true;
  43. end;
  44.  
  45. {
  46.   RIPcoder uninstall plugin by calling "pg_ClosePlugIn"
  47. }
  48. procedure pg_ClosePlugIn; stdcall;
  49. begin
  50.  { this is place for finalization }
  51. end;
  52.  
  53. {
  54.   RIPcoder send password for plugin.
  55.   Password sends each time before encryption/decryption.
  56. }
  57. procedure pg_GetPassword(ipwd: pchar); stdcall;
  58. var
  59.  i,j    : integer;
  60. begin
  61.  key32 := 0;
  62.  for i := 0 to strlen(ipwd)-1 do
  63.   begin
  64.   key32 := (key32 shl 4)+pbytearray(ipwd)[i];
  65.   j := key32 and $F0000000;
  66.   if j<>0 then key32 := key32 xor (j shr 24);
  67.   key32 := key32 and not j;
  68.   end;
  69. end;
  70.  
  71. {
  72.   RIPcoder gives plugin to work with source data divided by
  73.   many blocks, block size may differ
  74. }
  75.  
  76. procedure pg_EncodeBlock(var bf: array of byte;count: dword); stdcall;
  77. var
  78.  i,j    : integer;
  79.  sb    : byte;
  80. begin
  81.  j := 0;
  82.  for i:=0 to count-1 do
  83.   begin
  84.   sb := bf[i];
  85.   bf[i] := sb xor pbytearray(@key32)^[j];
  86.   pbytearray(@key32)^[j] := pbytearray(@key32)^[j] xor sb;
  87.   inc(j); if j=4 then j := 0;
  88.   end;
  89. end;
  90.  
  91. procedure pg_DecodeBlock(var bf: array of byte;count: dword); stdcall;
  92. var
  93.  i,j    : integer;
  94. begin
  95.  j := 0;
  96.  for i:=0 to count-1 do
  97.   begin
  98.   bf[i] := bf[i] xor pbytearray(@key32)^[j];
  99.   pbytearray(@key32)^[j] := pbytearray(@key32)^[j] xor bf[i];
  100.   inc(j); if j=4 then j := 0;
  101.   end;
  102. end;
  103.  
  104. exports
  105.  PlugIn_Name,
  106.  PlugIn_Version,
  107.  pg_InitPlugIn,
  108.  pg_ClosePlugIn,
  109.  pg_GetPassword,
  110.  pg_EncodeBlock,
  111.  pg_DecodeBlock;
  112.  
  113. end.